/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.aljfce.business.entity;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author Jacopo Ferrigno <jacopo.ferrigno@gmail.com>
 */
@Embeddable
public class CalendarPK implements Serializable {
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "User")
    private String user;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "CalendarName")
    private String calendarName;
    
    public static final String DEFAULT = "default";

    public CalendarPK() {
    }

    public CalendarPK(String user, String calendarName) {
        this.user = user;
        this.calendarName = calendarName;
    }
    
    public CalendarPK(String user) {
        this.user = user;
        this.calendarName = DEFAULT;
    }

    public String getUser() {
        return user;
    }

    public void setUser(String user) {
        this.user = user;
    }

    public String getCalendarName() {
        return calendarName;
    }

    public void setCalendarName(String calendarName) {
        this.calendarName = calendarName;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (user != null ? user.hashCode() : 0);
        hash += (calendarName != null ? calendarName.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CalendarPK)) {
            return false;
        }
        CalendarPK other = (CalendarPK) object;
        if ((this.user == null && other.user != null) || (this.user != null && !this.user.equals(other.user))) {
            return false;
        }
        if ((this.calendarName == null && other.calendarName != null) || (this.calendarName != null && !this.calendarName.equals(other.calendarName))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.aljfce.business.entity.CalendarPK[ user=" + user + ", calendarName=" + calendarName + " ]";
    }
    
}
